var donate = function () {
    layer.open({
        type: 2,
        title: false,
        area: ['806px', '467px'],
        closeBtn: 1,
        shadeClose: false,
        content: ['http://cdn.renren.io/donate.jpg', 'no']
    });
};
var IndexHandler = {
	newBreadcrumb:function(name){
		return '<li class="active menu">' + name +  '</li>';
	},
	init:function(){
		$(".treeview-menu a[target='main_frame'] ").click(function(){
			var breadcrumb = $(this).data('breadcrumb');
			var arr = breadcrumb.split(":"); 
			if(arr){
				$("#nav_title li").remove(".menu");
				$.each(arr, function(){ 
					$("#nav_title").append(IndexHandler.newBreadcrumb(this));
				});
			}
		});
	},
	updatePassword: function(){
		layer.open({
			type: 1,
			skin: 'layui-layer-molv',
			title: "修改密码",
			area: ['550px', '330px'],
			shadeClose: false,
			content: jQuery("#passwordLayer"),
			btn: ['修改','取消'],
			btn1: function (index) {
				var oldpwd = $("input[name='password']").val();
				var newpwd = $("input[name='newPassword']").val();
				var validpwd = $("input[name='newPwd']").val();
				var data = "oldpwd="+oldpwd+"&newpwd="+newpwd+"&validpwd="+validpwd;
				$.ajax({
					type: "POST",
				    url: "user/change-pwd",
				    data: data,
				    dataType: "json",
				    success: function(result){
						if(result && result.success){
							layer.close(index);
							layer.alert('修改成功', function(index){
								location.reload();
							});
						}else if(result && !result.success && result.data){
							layer.alert(result.data);
						}else{
							layer.alert(result.msg);
						}
					}
				});
            }
		});
	}
};
$(function(){
	IndexHandler.init();
});
//iframe自适应
$(window).on('resize', function() {
	var $content = $('.iframe-content');
	$content.height($(this).height() - 155);
	$content.find('iframe').each(function() {
		$(this).height($content.height());
	});
}).resize();
$("#iframeId").load(function () {
	var $content = $('.iframe-content');
	var a = $(window).height() - 155;
	var mainheight = $(this).contents().find("body").height() + 30;  
	$content.height(mainheight>a ? mainheight:a);
	$(this).height(mainheight>a ? mainheight:a);
});